<xsl:stylesheet version = '1.0'
    xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
    xmlns:cfd='http://www.sat.gob.mx/cfd/2'>
<xsl:import href="cadenaoriginal.xsl"/>

<xsl:output method = "html" /> 
 
<xsl:template match="//cfd:Comprobante">
   <html>
   <head>
   <link rel="STYLESHEET" media="screen" type="text/css" href="factura.css"/>
   <title>Factura Electronica <xsl:value-of select="@serie"/><xsl:value-of select="@folio"/></title>
   </head>
   <body>
   <table width="100%" border="0" >
      <tr><td class="img"><xsl:value-of select="//cfd:ExpedidoEn/@calle"/> #<xsl:value-of select="//cfd:ExpedidoEn/@noExterior"/>, <xsl:value-of select="//cfd:ExpedidoEn/@colonia"/>, <xsl:value-of select="//cfd:ExpedidoEn/@municipio"/>, <xsl:value-of select="//cfd:ExpedidoEn/@estado"/>, <xsl:value-of select="//cfd:ExpedidoEn/@pais"/> </td><td colspan="1" align="right">
          <table border="0">
               <tr><td class="h3">TIPO DE DOCUMENTO:</td><td class="h1"><xsl:value-of select="@tipoDeComprobante"/></td></tr>
               <tr><td class="h3">SERIE - FOLIO</td><td class="h1"><xsl:value-of select="@serie"/> - <xsl:value-of select="@folio"/></td></tr>

               <tr><td class="h3">FECHA Y HORA</td><td class="h1"><xsl:value-of select="@fecha"/></td></tr>
               <tr><td class="h3">LUGAR DE EXPEDICION</td><td class="h1"><xsl:value-of select="//cfd:ExpedidoEn/@municipio"/>, <xsl:value-of select="//cfd:ExpedidoEn/@estado"/></td></tr>
               <tr><td class="h3">ANO Y No. APROBACION</td><td class="h1"><xsl:value-of select="@anoAprobacion"/> - <xsl:value-of select="@noAprobacion"/></td></tr>
               <tr><td class="h3">No. DE CERTIFICADO</td><td class="h1"><xsl:value-of select="@noCertificado"/></td></tr>
               <tr><td class="h3">FECHA DE VENCIMIENTO</td><td class="h1">.</td></tr>

           </table>
           </td>
           </tr>
      <tr><td width="70%">
             <table width="100%" border="2" bordercolor="red">
               <tr><td class="h3" bordercolor="white">CLIENTE</td><td bordercolor="white"><xsl:value-of select="cfd:Receptor/@nombre"/></td></tr>
               <tr><td class="h3" bordercolor="white">DOMICILIO</td><td bordercolor="white"> <xsl:value-of select="//cfd:Domicilio/@calle"/> # <xsl:value-of select="//cfd:Domicilio/@noExterior"/> - <xsl:value-of select="//cfd:Domicilio/@noInterior"/> <xsl:value-of select="//cfd:Domicilio/@referencia"/>,
                <xsl:value-of select="//cfd:Domicilio/@colonia"/>, <xsl:value-of select="//cfd:Domicilio/@localidad"/></td></tr>
               <tr><td class="h3" bordercolor="white">POBLACION:</td><td bordercolor="white" ><xsl:value-of select="//cfd:Domicilio/@municipio"/>, <xsl:value-of select="//cfd:Domicilio/@estado"/>, <xsl:value-of select="//cfd:Domicilio/@pais"/></td></tr>
               <tr><td class="h3" bordercolor="white">RFC: </td><td bordercolor="white"><xsl:value-of select="cfd:Receptor/@rfc"/>  <font color="#003399">. CODIGO POSTAL </font>
               <xsl:if test="//cfd:Domicilio/@codigoPostal">  <xsl:value-of select="//cfd:Domicilio/@codigoPostal"/></xsl:if>
               </td></tr>
             </table>
          </td>
          <td width="30%">
             <table  width="100%" border="2" bordercolor="red"  cellspacing="0">
             <tr><td class="h3" bordercolor="blue">EMBARQUE</td><td bordercolor="#003399" class="h3">CONDICION</td></tr>
             <tr><td bordercolor="#003399">.</td><td bordercolor="#003399"><xsl:value-of select="@condicionesDePago"/></td></tr>
             <tr><td bordercolor="#003399" class="h3">AGENTE</td><td bordercolor="#003399" class="h3">FACTURO</td></tr>
             <tr><td bordercolor="#003399">.</td><td bordercolor="#003399">.</td></tr>
             </table>

           </td>
         </tr>
         <tr><table width="100%" border="2" bordercolor="red" cellspacing="0">
             <tr><th  bordercolor="#003399">CANTIDAD</th>
                 <th  bordercolor="#003399">PARTE</th>
                 <th  bordercolor="#003399">DESCRIPCION</th>
                 <th  bordercolor="#003399">PRECIO</th>
                 <th  bordercolor="#003399">IMPORTE</th>
             </tr>
             <xsl:apply-templates select="//cfd:Concepto"/>
             <xsl:for-each select="Concepto">
             </xsl:for-each>
              <tr ><td  bordercolor="red"  colspan="5">
                 <table width="100%" border="1" cellspacing="0">
                 <tr>
                   <th bordercolor="#003399" width="20%">SUMA</th>
                   <th  bordercolor="#003399" width="20%">DESCUENTO</th>
                   <th  bordercolor="#003399" width="20%">SUBTOTAL</th>
                   <th bordercolor="#003399" width="20%">IVA</th>
                   <th bordercolor="#003399" width="20%">TOTAL</th>
                 </tr>
                 <tr>
                   <td bordercolor="#003399" align="right"><xsl:value-of select="format-number(@subTotal, '###,###.00')"/></td>
                   <xsl:if test="@descuento"><td bordercolor="#003399" align="right"><xsl:value-of select="format-number(@descuento, '###,##0.00')"/></td></xsl:if>
		   <xsl:if test="not(@descuento)"><td bordercolor="#003399" align="right"><xsl:value-of select="0.0"/></td></xsl:if>
                   <xsl:if test="@descuento"><td bordercolor="#003399" align="right"><xsl:value-of select="format-number((@subTotal)- @descuento, '###,###.00')"/></td></xsl:if>
		   <xsl:if test="not(@descuento)"><td bordercolor="#003399" align="right"><xsl:value-of select="@subTotal"/></td></xsl:if>
                   <td bordercolor="#003399" align="right">(<xsl:value-of select="//cfd:Traslado/@tasa"/> %) <xsl:value-of select="format-number(//cfd:Traslado/@importe, '###,###.00')"/></td>
                  <td bordercolor="#003399" align="right"><xsl:value-of select="format-number(@total, '###,###.00')"/></td>
                 </tr>
                 </table>
             </td></tr>


            </table>
         </tr><hr/>
         <tr> <td>
         <table width="100%" border="2" bordercolor="red" cellspacing="0" align="center">

            <tr><th bordercolor="#003399" >CADENA ORIGINAL</th></tr>
            <tr><td bordercolor="#003399" >
            <xsl:apply-imports/>
            </td></tr>
            <tr><th bordercolor="#003399" >SELLO DIGITAL</th></tr>
            <tr><td bordercolor="#003399" class="sello"><small><xsl:value-of select="@sello"/></small></td></tr>
        </table>
              </td>
         </tr>
         <tr><td width="100%"> <center>
        Este documento es una impresion de un comprobante fiscal digital
        </center></td></tr>
        </table>


    </body>
    </html>
</xsl:template>
 
 
<xsl:template match="//cfd:DomicilioFiscal">
    <tr><th colspan="2" class="h2">Domicilio</th></tr>
    <tr><td colspan="2"><xsl:value-of select="@calle"/> # <xsl:value-of select="@noExterior"/> - <xsl:value-of select="@noInterior"/></td></tr>
    <tr><td colspan="2"><xsl:value-of select="@colonia"/></td></tr>
    <tr><td colspan="2"><xsl:value-of select="@localidad"/></td></tr>
    <tr><td colspan="2"><xsl:value-of select="@referencia"/></td></tr>
    <tr><td colspan="2"><xsl:value-of select="@municipio"/>
    <xsl:if test="@codigoPostal"> CODIGO POSTAL <xsl:value-of select="@codigoPostal"/></xsl:if>
         </td></tr>
     <tr><td colspan="2"><xsl:value-of select="@estado"/></td></tr>
     <tr><td colspan="2"><xsl:value-of select="@pais"/></td></tr>
</xsl:template>
 
<xsl:template match="//cfd:Domicilio">
    <tr><th colspan="2" class="h2">Domicilio</th></tr>
    <tr><td colspan="2"><xsl:value-of select="@calle"/> # <xsl:value-of select="@noExterior"/> - <xsl:value-of select="@noInterior"/></td></tr>
    <tr><td colspan="2"><xsl:value-of select="@colonia"/></td></tr>
    <tr><td colspan="2"><xsl:value-of select="@localidad"/></td></tr>
    <tr><td colspan="2"><xsl:value-of select="@referencia"/></td></tr>

    <tr><td colspan="2">Poblacion <xsl:value-of select="@municipio"/>, <xsl:value-of select="@estado"/></td></tr>
    <tr><td colspan="2"><xsl:value-of select="@pais"/></td></tr>
    <tr><td colspan="2">RFC: <xsl:value-of select="cfd:Receptor/@rfc"/>  CODIGO POSTAL
        <xsl:if test="@codigoPostal">  <xsl:value-of select="@codigoPostal"/></xsl:if>
        </td></tr>
</xsl:template>
 
<xsl:template match="//cfd:Concepto">
    <tr><td bordercolor="#003399" align="center"><xsl:value-of select="@cantidad"/></td>
        <td bordercolor="#003399" align="center"><xsl:value-of select="@noIdentificacion"/></td>
        <td bordercolor="#003399"><xsl:value-of select="@descripcion"/>
              <xsl:if test="cfd:InformacionAduanera"> -->> Pedimento=<xsl:value-of select="cfd:InformacionAduanera/@numero"/> Fecha=<xsl:value-of select="cfd:InformacionAduanera/@fecha"/> Aduana=<xsl:value-of select="cfd:InformacionAduanera/@aduana"/></xsl:if>
        </td>
        <td bordercolor="#003399" align="right"><xsl:value-of select="@valorUnitario"/></td>
        <td bordercolor="#003399" align="right"><xsl:value-of select="format-number(@importe, '###,###.00')"/></td>
    </tr>
    <xsl:comment><xsl:if test="cfd:InformacionAduanera">
        <tr><td align="center">.</td>
        <td>Pedimento=<xsl:value-of select="cfd:InformacionAduanera/@numero"/> Fecha=<xsl:value-of select="cfd:InformacionAduanera/@fecha"/> Aduana=<xsl:value-of select="cfd:InformacionAduanera/@aduana"/></td>
        <td align="right">.</td>
        <td align="right">.</td>
    </tr>
    </xsl:if>    </xsl:comment>
</xsl:template>
 
<xsl:template match="//cfd:Traslado">
    <tr><td colspan="2" align="right"></td>
        <td align="right"><xsl:value-of select="@impuesto"/> (<xsl:value-of select="@tasa"/> %)</td>
        <td align="right"><xsl:value-of select="format-number(@importe, '###,###.00')"/></td>
    </tr>
</xsl:template>
 
</xsl:stylesheet>

